package q900_q1000;

/**
 * @Author: wzp
 * @CreateTime: 2024-09-08  14:00
 * @Description: TODO
 * @Version: 1.0
 */
public class question_977 {
    public int[] test(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            nums[i]=nums[i]*nums[i];
        }
        int start=0;
        int end=nums.length-1;
        int [] res=new int[nums.length];
        int index=nums.length-1;
        while (start<end){
            if(nums[start]<nums[end]){
                res[index--]=nums[end];
                end--;
            }else {
                res[index--]=nums[start];
                start++;
            }
        }
        res[index]=nums[start];
        return res;
    }

    public void setZeroes(int[][] matrix) {
        int[] arr_row=new int[matrix.length];
        int[] arr_col=new int[matrix[0].length];
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[i].length; j++) {
                if(matrix[i][j]==0){
                    arr_row[i]=1;
                    arr_col[j]=1;
                }
            }

        }
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[i].length; j++) {
                if(arr_row[i]==1||arr_col[j]==1){
                    matrix[i][j]=0;
                }
            }

        }
        return;
    }
}
